1. Start
  2. Installation
  3. Database Structure
  4. Directory and File Structure
  5. URL Structure
  6. PHP Libraries
  7. Menu Manager Operations
  8. Displaying Menu
  9. Sources and Credits

Easy Menu Manager

Documentation


Thank you for purchasing my script. If you have any questions that are beyond the scope of this help file, please feel free to email via my user page contact form here:
http://codecanyon.net/user/gawibowo
Thanks so much!

Installation


Server Requirements:

Upload Files

Extract the main zip file, and then upload the easymenu folder to your server.

Configuration File

Open config.php file and edit these values:

// Base URL
define('_BASE_URL', 'http://yoursite.com/easymenu/');
Change this with your url path of this application
// Database Connection Settings
define('DB_HOST', 'localhost');
define('DB_USER', 'root');
define('DB_PASS', 'password');
define('DB_NAME', 'easymenu');
Change this with your database settings (host, user, password, database name).
// Admin Login
define('ADMIN_USER', 'admin');
define('ADMIN_PASS', 'mypassword');
Change this with your username and password for accessing menu manager.
If you want to disable login, just fill the value with an empty string.

Database Setup

Database Structure


The database has 2 tables: menu and menu_group.

If you rename the tables or fields, you must change the table and field names configuration in the config.php

// Tables Settings
define('MENU_TABLE', 'menu');
define('MENUGROUP_TABLE', 'menu_group');

// Fields Settings
define('MENU_ID', 'id');
define('MENU_PARENT', 'parent_id');
define('MENU_TITLE', 'title');
define('MENU_URL', 'url');
define('MENU_CLASS', 'class');
define('MENU_POSITION', 'position');
define('MENU_GROUP', 'group_id');

Directory and File Structure


URL Structure


This application uses a framework with this url structure:

index.php?act=controller.method

controller is the name of the file in the modules directory
method is the method inside the controller file

For example: index.php?act=news.detail&id=1
This url means the application will search file in modules/news.php, and the method detail inside this file will be executed

PHP Libraries


These are the php class libraries used in this application:

DB

This is the class for database operations.
Some code example:
include _DOC_ROOT . 'includes/db.php';

$db = new DB;

//connect to database
$db->Connect('localhost', 'root', 'pass', 'dbname');

//execute a delete query
$db->Execute("DELETE FROM account WHERE id = 15");

//get multi rows result from a SELECT query, return an array
$data = $db->GetAll("SELECT * FROM account LIMIT 10");
print_r($data);

//get one result from a SELECT query, return a string
$name = $db->GetOne("SELECT name FROM account WHERE id = 1");
echo $name;

//get one row result from a SELECT query, return an array
$row = $db->GetRow("SELECT username, password, name FROM account WHERE id = 1");
print_r($row);

//get one column from a SELECT query, return an array
$username = $db->GetCol("SELECT username FROM account ORDER BY id LIMIT 10");
print_r($username);

//quick insert from an array data
$data['username'] = 'myusername';
$data['password'] = '123456';
$data['name'] = 'My Name';
$data = $db->insert('account', $data);

//quick update from an array data
$data['username'] = 'user';
$data['password'] = 'admin';
$data['name'] = 'My Real Name';
$data = $db->update('account', $data, 'id = 1');

Tree

This is the class for generating html nested lists.
Some code example:
include _DOC_ROOT . 'includes/tree.php';
$tree = new Tree;
$tree->add_row(1, 0, '', 'Menu 1');
$tree->add_row(2, 0, '', 'Menu 2');
$tree->add_row(3, 1, '', 'Menu 1.1');
$tree->add_row(4, 1, '', 'Menu 1.2');
echo $tree->generate_list();
Output:
<ul>
    <li>Menu 1
        <ul>
            <li>Menu 1.1</li>
            <li>Menu 1.2</li>
        </ul>
    </li>
    <li>Menu 2</li>
</ul>

Displaying Menu


If you have finished adding menus in menu manager, now you have the menu data ready to be displayed. This is an example of how to create controller and view to display the menu in public.

Sources and Credits


I've used the following scripts and icons: